package com.openx.xoj.service.impl;

import com.openx.xoj.mapper.ExaminationQuestionMapper;
import com.openx.xoj.model.Teacher.ExamQuestion;
import com.openx.xoj.service.ExaminationQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExaminationQuestionServiceImpl implements ExaminationQuestionService {

    @Autowired
    private ExaminationQuestionMapper examinationQuestionMapper;

    @Override
    public void addQuestionToExam(long examId, long questionId) {
        // 插入数据
        System.out.println("Inserting examId: " + examId + ", questionId: " + questionId);
        examinationQuestionMapper.insertExamQuestion(examId, questionId);
    }

    @Override
    public void removeQuestionFromExam(long examId, long questionId) {
        // 删除数据
        System.out.println("Deleting examId: " + examId + ", questionId: " + questionId);
        examinationQuestionMapper.deleteExamQuestion(examId, questionId);
    }

    @Override
    public List<ExamQuestion> getQuestionsByExamId(long examId) {
        List<ExamQuestion> questionsByExamId = examinationQuestionMapper.findQuestionsByExamId(examId);
        System.out.println(questionsByExamId);
        return questionsByExamId;
    }

    @Override
    public List<ExamQuestion> findQuestionsByExamId(long examId) {
        return examinationQuestionMapper.findQuestionsByExamId(examId);
    }
}
